 <html>
<head>

<script type="text/javascript" src="build/yahoo/yahoo-min.js"></script>
<script type="text/javascript" src="build/event/event-min.js"></script>
<script type="text/javascript" src="build/connection/connection-min.js"></script>

<script type="text/javascript" src="init.js"></script>
<script type="text/javascript" src="dasParsers.js"></script>
<script type="text/javascript" src="classes.js"></script>

<script>
	
/*
 * Gloabl object
 */
YAHOO.namespace("dasRegistry");	
YAHOO.dasRegistry = {
		specie: "Homo sapiens", //*** NOTA: Aqui defines la especie
		result: new Object(), //*** NOTA: Aqui se guardan los resultados
	}
	
/*
 * Ajax request to the DAS registry
 */
function makeRegistryRequest(){
	var proxyUrl = YAHOO.dasBrowser.genome.karyotypeStructure.proxyUrl;
	var sourceParameter = YAHOO.dasBrowser.proxy.parameters.source; // s
	var registryUrl = "http://www.dasregistry.org/das1/sources";
	var typeParameter = "Chromosome";
	var organismParameter = YAHOO.dasRegistry.specie;
	//*** NOTA: He modificado un poco el proxy.php para que me pueda detectar los parametros URL del Registro. Mira proxy.php.	
	var url =  proxyUrl + "?" + sourceParameter + "=" + registryUrl + "?type=" + typeParameter + "&organism=" + organismParameter;
	//console.log(url);
	
    var request = YAHOO.util.Connect.asyncRequest('GET', url, registryRequestCallback);
}


/*
 * Callback for the ajax request to the DAS registry
 */
var registryRequestCallback = {
    success:function(o){
		YAHOO.dasRegistry.result = YAHOO.dasBrowser.dasRegistry.parse(o.responseXML);
		printResult(); //*** NOTA: Aqui un print para que veas un ejemplo.
    },
    failure:function(o){
		console.log("failure");
	}
}


/*
 * Example
 */
function printResult(){
	for (var i = 0; i < YAHOO.dasRegistry.result.sources.length; i++) {
		var sourceUrl = null;
		for (var j = 0; j < YAHOO.dasRegistry.result.sources[i].capability.length; j++) {
			if (YAHOO.dasRegistry.result.sources[i].capability[j].type == "das1:features") {
				sourceUrl = YAHOO.dasRegistry.result.sources[i].capability[j].queryUri;
			}
		}
		if (sourceUrl != null) {
			console.log("source.id = " + YAHOO.dasRegistry.result.sources[i].uri);
			console.log("source.url = " + sourceUrl);
			console.log("source.name = " + YAHOO.dasRegistry.result.sources[i].title);
			console.log("source.label = " + YAHOO.dasRegistry.result.sources[i].label);
			console.log("source.description = " + YAHOO.dasRegistry.result.sources[i].description);
			console.log("source.representation = \"chart\"");
			console.log("- - - - - - - - - - - - - - - - - - - - - - - - -");
		}
	}
}


/*
 * Initialization
 */
YAHOO.util.Event.addListener(window, 'load', makeRegistryRequest);

</script>
    </head>
    <body>
    </body>
</html>
